/*
 * @LastEditors: yuSeen
 * @LastEditTime: 2021-12-29 18:28:12
 */
import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'
import customParseFormat from 'dayjs/plugin/customParseFormat'
dayjs.extend(customParseFormat)
dayjs.locale('zh-cn')

export const useTime = () => {

    // 根据时间戳获取年月日
    const unixToYMD = (timestamp: number, format: string = 'YYYY-MM-DD') => {
        // if(timestamp.toString().length > 10) return dayjs(timestamp / 1000)
        return dayjs(timestamp).format(format)
    }
    return {
        unixToYMD
    }
}